import numpy as np
import matplotlib.pyplot as plt
def linkPre_figure(dataset = '',AUC = [],pre = [],weak_pre = [],components = [],method = '',name = '',ori_AUC = 0,ori_pre = 0,ori_weak_pre = 0):
    plt.xticks(components)
    plt.yticks(np.linspace(0,1,30))
    x =components
    ori_AUCs = np.repeat(ori_AUC, len(AUC))
    ori_pres = np.repeat(ori_pre, len(pre))
    ori_ori_weak_pres = np.repeat(ori_weak_pre, len(weak_pre))
    plt.plot(x, ori_AUCs, color = 'g',label='ori_AUC')
    plt.plot(x, ori_pres, color = 'b',label='ori_pre')
    plt.plot(x, ori_ori_weak_pres, color = 'r',label='ori_weak_pre')
    plt.plot(x, AUC,label='AUC',color = 'g',marker = "o")
    plt.plot(x, pre,label='pre',color = 'b',marker = "x")
    plt.plot(x, weak_pre,label='weak_pre',color = 'r',marker = "^")
    plt.title(method+'-'+dataset+'-'+name)
    plt.xlabel('embedding_size')
    plt.legend()
    plt.savefig("{}.png".format(method+'-'+dataset+'-'+name))
    plt.show()

def linkPre_figure2(datasets = [],scores = [],ori_scores=[],scores_name = '',components = [],method = '',name = ''):
    plt.xticks(components)
    # plt.yticks(np.linspace(0.8,1,30))
    x = components
    colors = ['g','b','y','c','m']
    marker = ["o","x","^",".","+"]
    for i in range(5):
        plt.plot(x, scores[i],label=datasets[i],color=colors[i], marker=marker[i])
        plt.plot(x, np.repeat(ori_scores[i],len(components)), label='ori-'+datasets[i],color=colors[i])
    # ori_ori_weak_pres = np.repeat(ori_weak_pre, len(weak_pre))
    # plt.plot(x, ori_AUCs, color = 'g',label='ori_AUC')
    # plt.plot(x, ori_pres, color = 'b',label='ori_pre')
    # plt.plot(x, ori_ori_weak_pres, color = 'r',label='ori_weak_pre')
    # plt.plot(x, AUC,label='AUC',color = 'g',marker = "o")
    # plt.plot(x, pre,label='pre',color = 'b',marker = "x")
    # plt.plot(x, weak_pre,label='weak_pre',color = 'r',marker = "^")
    plt.title(method+'-'+name)
    plt.xlabel('embedding_size')
    plt.legend()
    plt.savefig("{}.png".format(method+'-'+name))
    plt.show()


if __name__ == '__main__':
    datasets = ['Amherst','PB','Facebook','hamster','Oberlin','SC_TS','USAir','Wellesley']
    # AUC = [0.9412,0.9408,0.9387,0.9451,0.9434,0.9463,0.9469,0.9485]
    # AUC = [0.749,0.7485,0.7479,0.7469,0.7467,0.7467,0.7456,0.7433]
    # pre = [0.3953,0.3845,0.3591,0.4089,0.4034,0.4169,0.4158,0.4281]
    # pre = [0.1806,0.1839,0.1837,0.1847,0.1868,0.1888,0.1893,0.1907]
    # weak_pre = [0.4003,0.4033,0.3932,0.4173,0.4325,0.4439,0.4485,0.4609]
    # weak_pre = [0.2333,0.2371,0.2358,0.2366,0.2392,0.239,0.2393,0.2393]
    # components = [128,132,135,140,145,150,155,160]
    score0 = [0.4003,0.4033,0.3932,0.4173,0.4325,0.4439,0.4485,0.4609]
    score1 = [0.3585,0.3632,0.3546,0.3747,0.3763,0.3837,0.3831,0.3867]
    score2 = [0.4866,0.501,0.5208,0.5199,0.5338,0.536,0.5514,0.5434]
    score3 = [0.2132,0.1809,0.1462,0.2276,0.2061,0.1969,0.1664,0.2247]
    score4 = [0.2263,0.238,0.2209,0.2482,0.2462,0.2525,0.2686,0.2824]
    score5 = [0.2718,0.3344,0.2725,0.2779,0.3733,0.3168,0.3229,0.3595]
    score6 = [0.78,0.77,0.7843,0.7986,0.8143,0.8071,0.8071,0.8243]
    score7 = [0.2497,0.2485,0.2395,0.2631,0.267,0.2742,0.2803,0.286]
    scores = []
    for i in range(8):
      scores.append(locals()['score'+str(i)])
    ori_score0 = 0.249
    ori_score1 = 0.0047
    ori_score2 = 0.3963
    ori_score3 = 0.0007
    ori_score4 = 0.2002
    ori_score5 = 0.6756
    ori_score6 = 0.2643
    ori_score7 = 0.1918
    ori_scores = []
    for i in range(8):
      ori_scores.append(locals()['ori_score'+str(i)])

    score_pre0 = [0.3953,0.3845,0.3591,0.4089,0.4034,0.4169,0.4158,0.4281]
    score_pre1 = [0.3593,0.3684,0.3496,0.3774,0.3675,0.3712,0.3691,0.3651]
    score_pre2 = [0.636,0.6433,0.6332,0.6577,0.667,0.6667,0.6678,0.6729]
    score_pre3 = [0.1439,0.1119,0.0848,0.1541,0.141,0.1298,0.0955,0.1438]
    score_pre4 = [0.2309,0.2349,0.2143,0.2474,0.2423,0.247,0.2528,0.2637]
    score_pre5 = [0.1033,0.1268,0.1025,0.1076,0.1403,0.1157,0.1187,0.1301]
    score_pre6 = [0.4825,0.4807,0.4665,0.4958,0.5127,0.5005,0.4755,0.4929]
    score_pre7 = [0.2259,0.223,0.205,0.2386,0.2365,0.2452,0.2449,0.2547]
    scores_pre = []
    for i in range(8):
        scores_pre.append(locals()['score_pre' + str(i)])
    ori_score_pre0 = 0.2778
    ori_score_pre1 = 0.0326
    ori_score_pre2 = 0.407
    ori_score_pre3 = 0.0002
    ori_score_pre4 = 0.2315
    ori_score_pre5 = 0.8663
    ori_score_pre6 = 0.2646
    ori_score_pre7 = 0.2244
    ori_scores_pre = []
    for i in range(8):
        ori_scores_pre.append(locals()['ori_score_pre' + str(i)])
    # # ori_AUCs.append(ori_AUC1,ori_AUC2,ori_AUC3,ori_AUC4,ori_AUC5)
    # components = [128, 132, 135, 140, 145, 150, 155, 160]
    # score0 = [0.9412,0.9408,0.9387,0.9451,0.9434,0.9463,0.9469,0.9485]
    # score1 = [0.9498,0.9514,0.9505,0.9536,0.9536,0.9554,0.9548,0.9548]
    # score2 = [0.996,0.9961,0.996,0.9964,0.9965,0.9965,0.9965,0.9966]
    # score3 = [0.9664,0.9647,0.9549,0.9686,0.9665,0.9668,0.9604,0.9693]
    # score4 = [0.9312,0.9321,0.9304,0.934,0.9345,0.9356,0.9375,0.9382]
    # score5 = [0.9907,0.9906,0.9899,0.9909,0.9919,0.9905,0.9898,0.9907]
    # score6 = [0.9641,0.9658,0.9638,0.9678,0.9652,0.9666,0.9672,0.9687]
    # score7 = [0.9295,0.9297,0.927,0.9319,0.9324,0.9342,0.9347,0.9366]
    # scores = []
    # for i in range(8):
    #     scores.append(locals()['score' + str(i)])
    # ori_score0 = 0.9098
    # ori_score1 = 0.8665
    # ori_score2 = 0.9916
    # ori_score3 = 0.961
    # ori_score4 = 0.9094
    # ori_score5 = 0.996
    # ori_score6 = 0.9192
    # ori_score7 = 0.9097
    # ori_scores = []
    # for i in range(8):
    #     ori_scores.append(locals()['ori_score' + str(i)])
    components = [128, 132, 135, 140, 145, 150, 155, 160]
    x = components
    plt.yticks(np.linspace(0, 1, 70))
    colors = ['g', 'black', 'y', 'c', 'm', 'chocolate', 'navy', 'lime', 'lime']
    marker = ["o", "x", "^", ".", "+", "1", "2", "3", "4", "5"]
    for i in range(8):
        plt.plot(x, scores_pre[i], label='pca-'+datasets[i], color=colors[i], marker=marker[i],linewidth=1.0)
        plt.plot(x, scores[i], label='pca-'+datasets[i] + '-weak', color=colors[i], marker=marker[i], linestyle=':',linewidth=2.0)
        plt.plot(x, np.repeat(ori_scores_pre[i], len(components)), label='ori-' + str(datasets[i]), color=colors[i],linewidth=1.0)
        plt.plot(x, np.repeat(ori_scores[i], len(components)), label='ori-' + str(datasets[i]) + '-weak',
                 color=colors[i],linewidth=2.0,linestyle=':')

    plt.title('node2vec' + '-pre+weak_pre')
    plt.xlabel('embedding_size')
    plt.legend()
    plt.savefig("{}.png".format('node2vec' + '-' + 'MLP' + '-pre+weak_pre'))
    plt.show()